/* Project 7 Virtual Machine
   File: parser.h */
#include "token.h"

/* Structure to hold data for a Parameter */
struct Parameter
{
	enum DataType t;
	union 
	{
		float f;
		int i;
		char *str;
		char *lbl;
		enum Register r;
	} v;
};

/* Structure to hold the state of the VM */
struct VirtualMachineState
{
	struct RegisterData registers[REGISTERCOUNT];
	struct Instruction
	{
		void (*f)(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);
		struct Parameter p1, p2;
	} *instructions;
	int instruction_index, instruction_count;
};

/* Functions to create and run code on a virtual machine */
struct VirtualMachineState Create_Virtual_Machine();
int Create_Instruction_Set(struct VirtualMachineState *virtual_machine,
						struct TokenList token_list, FILE* error_file);
void Execute_Code(struct VirtualMachineState *virtual_machine);
void Free_VirtualMachine(struct VirtualMachineState *virtual_machine);
void Label_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);	//{Brad Klingensmith}
void Goto_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);	//{Matt Sparkman}
void Jmnz_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);	//{Matt Sparkman}
void Jmz_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);	//{Matt Sparkman}
void Jmp_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);	//{Matt Sparkman}
void Jmn_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);	//{Matt Sparkman}
void Mov_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);	//{Abdullah Alosayef}
void Add_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);        //{Abdullah Alosayef}
void Sub_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);        //{Abdullah Alosayef}
void Mul_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);        //{Abdullah Alosayef}
void Div_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);        //{Sherm Newsome}
void Get_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);        //{Sherm Newsome}
void Fget_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);        //{Sherm Newsome}
void Put_Func(struct VirtualMachineState *virtual_machine, struct Parameter p1, struct Parameter p2);        //{Sherm Newsome}
